import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:speed_random/app_styles.dart';
import 'package:speed_random/common/common_fuc.dart';
import 'package:speed_random/global_data.dart';
import 'package:speed_random/pages/home/rand_com/rand_com_args.dart';
import 'package:speed_random/widgets/item_home_list.dart';
import 'package:share_plus/share_plus.dart';


class Home extends StatefulWidget {
  Home({Key? key}) : super(key: key);


  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> with WidgetsBindingObserver {

  final GlobalKey shareKey = GlobalKey();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //backgroundColor: AppStyles.colorPagebg,
      appBar: AppBar(
        title: Text("Speed Random".tr),
       // backgroundColor: AppStyles.colorAppBarbg,
        actions: [
          //vip按钮
         /*GestureDetector(
           onTap: (){
             //VIP购买

           },
           child:  Image.asset(
             "assets/images/icons/vip.png",
             color: commonFuc.hexToColor("#a770ef"),
             fit: BoxFit.cover,
             width: 30,
           ),
         ),*/
          IconButton(
            icon: Icon(Icons.share),
            onPressed: () async{
              // 构建包含应用名称和下载链接的分享文本
              var shareText = globalData.appShareText.tr+"\n${globalData.appInfo.ch?.updateUrl}\n";

              commonFuc.shareImageWithText(boundaryKey: shareKey, text: shareText,title: globalData.appName);
            },
          ),
          IconButton(
            icon: Icon(Icons.settings),
            onPressed: () {
              Get.toNamed('/settings');
            },
          ),
        ],
      ),
      body: RepaintBoundary(
        key: shareKey,
      child:
      Padding(

        padding: const EdgeInsets.all(10.0),
        child:  ListView(
            children: [

              itemHomeList(text: "随机数生成".tr, imagePath: "assets/images/123.png"
                  , backgroundColor: Color(0xff0245b5), onTap: (){
                Get.toNamed('/rand_num');
              }),
           
             /* itemHomeList(text: "自定义随机列表", imagePath: "assets/images/icons/home_list.png", backgroundColor: Color(0xff0245b5), onTap: (){
                Get.toNamed('/rand_list');
              }),*/


              itemHomeList(

                text: "自定义随机列表".tr,
                imagePath:  "assets/images/icons/home_list.png",
                backgroundColor: Color(0xffed5485),
                onTap: (){
                  Get.toNamed('/rand_list', arguments: RandComArgs(
                    title: "自定义随机列表".tr,
                    list: "",
                    cachekey: "rand_list_list",
                    colorPagebg: Color(0xffffffff), // 添加背景色参数
                    colorPageText: AppStyles.colorOkButbg, // 添加文字颜色参数
                  ).toMap());
                },
              ),
              itemHomeList(
                text: "密码生成".tr,
                imagePath: "assets/images/icons/paw.png",
                backgroundColor: Color(0xff0245b5),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "密码生成".tr,
                    list: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
                    cachekey: "rand_com_password",
                    /* colorPagebg: commonFuc.hexToColor("#ffd3b6"), // 添加背景色参数
                    colorPageText: Color(0xffeaaf0c), // 添加文字颜色参数*/
                    settingkeys: "autostop,time",
                  ).toMap());
                },
              ),

              itemHomeList(
                text: "抛硬币".tr,
                imagePath:  "assets/images/icons/home_toss.png",
                backgroundColor: Color(0xffed5485),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "抛硬币".tr,
                    list: "正面,反面",
                    cachekey: "rand_com_toss",
                    colorPagebg: Color(0xffffffff), // 添加背景色参数
                    colorPageText: Color(0xff101010), // 添加文字颜色参数
                    settingkeys: "q",
                  ).toMap());
                },
              ),

              itemHomeList(
                text: "是或否?".tr,
                imagePath: "assets/images/icons/home_yesno.png",
                backgroundColor: Color(0xff0245b5),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "是或否?".tr,
                    list: "是,否",
                    cachekey: "rand_com_yesornot",
                   /* colorPagebg: commonFuc.hexToColor("#ffd3b6"), // 添加背景色参数
                    colorPageText: Color(0xffeaaf0c), // 添加文字颜色参数*/
                    settingkeys: "autostop,time",
                  ).toMap());
                },
              ),



           
              itemHomeList(
                text: "⚀ ⚁ ⚂ ⚃ ⚄ ⚅",
                imagePath: "assets/images/icons/home_roller.png",
                backgroundColor: Color(0xff0245b5),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "⚀ ⚁ ⚂ ⚃ ⚄ ⚅",
                    list: "⚀,⚁,⚂,⚃,⚄,⚅,⚀,⚁,⚂,⚃,⚄,⚅",
                    cachekey: "rand_com_roller",
                    colorPagebg: Color(0xffffe6eb), // 添加背景色参数
                    colorPageText: Color(0xff101010), // 添加文字颜色参数
                    settingkeys: "autostop,time,num,iscf",
                  ).toMap());
                },
              ),

           
              itemHomeList(
                text: "✊✌️✋",
                imagePath:  "assets/images/icons/home_rps.png",
                backgroundColor: Color(0xff0245b5),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "✊✌️✋",
                    list: "✊,✌️,✋",
                    cachekey: "rand_com_rps",
                    colorPagebg: commonFuc.hexToColor("#62d2a2"), // 添加背景色参数
                    colorPageText: Color(0xff101010), // 添加文字颜色参数
                    settingkeys: "autostop,time",
                  ).toMap());
                },
              ),
           

              itemHomeList(
                text: "随机颜色".tr,
                imagePath:  "assets/images/icons/home_color.png",
                backgroundColor: Color(0xff0245b5),
                onTap: (){
                  Get.toNamed('/rand_com', arguments: RandComArgs(
                    title: "随机颜色".tr,
                    list: "#e6f7ff,#ffebee,#f3e5f5,#e8f5e9,#fff8e1,#e0f7fa,#fbe9e7,#efebe9,#e8eaf6,#f1f8e9,#fff3e0,#e0f2f1,#fce4ec,#e1bee7,#d0d9ff,#b2dfdb,#ffecb3,#ffccbc,#d7ccc8,#cfd8dc,#b3e5fc,#c8e6c9,#ffcdd2,#f8bbd0,#d1c4e9,#b39ddb,#80deea,#a5d6a7,#ffe082,#ffab91,#bcaaa4,#90a4ae,#81d4fa,#aed581,#f48fb1,#ce93d8,#9fa8da,#4dd0e1,#81c784,#ffd54f,#ff8a65,#8d6e63,#78909c,#4fc3f7,#7cb342,#f06292,#ba68c8,#7986cb,#26c6da,#66bb6a,#ffb74d,#ff7043,#6d4c41,#546e7a,#29b6f6,#43a047,#e57373,#ab47bc,#5c6bc0,#00acc1,#4caf50,#ffa726,#f4511e,#5d4037,#455a64,#0288d1,#388e3c,#ef5350,#8e24aa,#3949ab,#00838f,#2e7d32,#fb8c00,#d84315,#4e342e,#37474f,#01579b,#1b5e20,#d32f2f,#6a1b9a,#303f9f,#006064,#1b5e20,#f57c00,#bf360c,#3e2723,#263238,#80d8ff,#b9f6ca,#ff9e80,#b388ff,#82b1ff,#84ffff,#ccff90,#ffff8d,#ff80ab,#ea80fc,#8c9eff,#80deea,#a7ffeb,#ffd180,#ff8a80,#b388ff,#82b1ff,#84ffff,#ccff90,#ffff8d,#ff80ab,#ea80fc,#8c9eff,#80deea,#a7ffeb,#ffd180",
                    cachekey: "rand_com_color",
                    colorPagebg: Color(0xffffffff), // 添加背景色参数
                    colorPageText: Color(0xff101010), // 添加文字颜色参数
                    settingkeys: "autostop,time,num,iscf",
                  ).toMap());
                },
              ),



              itemHomeList(
                text: "自定义转盘".tr,
                imagePath:  "assets/images/icons/home_spin.png",
                backgroundColor: Color(0xffed5485),
                onTap: (){
                  Get.toNamed('/rand_list', arguments: RandComArgs(
                    title: "自定义转盘".tr,
                    list: "",
                    cachekey: "rand_com_spin_wheel",
                    colorPagebg: Color(0xffffffff), // 添加背景色参数
                    colorPageText: AppStyles.colorOkButbg, // 添加文字颜色参数
                    settingkeys: "1",
                  ).toMap());
                },
              ),
              itemHomeList(
                text: "旋转勺子".tr,
                imagePath:  "assets/images/icons/home_bottle.png",
                backgroundColor: Color(0xffed5485),
                onTap: (){
                  Get.toNamed('/spin_bottle_list', arguments: RandComArgs(
                    title: "旋转勺子".tr,
                    list: "",
                    cachekey: "spin_bottle",
                    colorPagebg: Color(0xffffffff), // 添加背景色参数
                    colorPageText: Color(0xff101010), // 添加文字颜色参数
                    settingkeys: "1",
                  ).toMap());
                },
              ),
            ]
        ),
      ),
      )
    );
  }
}